﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Groups.aspx.cs" Inherits="MonkeyWarranty.Web.Suppliers.Groups" %>
<%@ Import Namespace="Resources" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <title><%=GlobalStrings.SupplierGroups %></title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <p>
        <a href="Groups.aspx" class="a-selected"><%= GlobalStrings.SupplierGroups %></a>&nbsp;|&nbsp;
        <a href="List.aspx"><%= GlobalStrings.Suppliers %></a>
    </p>
    <div id="SupplierGroupsTableContainer">
    </div>
    <p><input type="button" value="<%=GlobalStrings.AddNew %>" onclick="javascript:window.location='NewGroup.aspx';" /></p>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#SupplierGroupsTableContainer').jtable({
                title: '<%=GlobalStrings.SupplierGroups %>',
                actions: {
                    listAction: 'Groups.aspx/GroupList',
                    //createAction: 'Groups.aspx/CreateGroup',
                    //updateAction: 'Groups.aspx/UpdateGroup',
                    deleteAction: 'Groups.aspx/DeleteGroup'
                },
                fields: {
                    Id: {
                        key: true,
                        create: false,
                        edit: false,
                        list: false
                    },
                    Code: {
                        title: '<%=GlobalStrings.Code %>',
                        width: '10%',
                        defaultValue: 'NNCC',
                        inputClass: 'validate[required]'
                    },
                    Name: {
                        title: '<%=GlobalStrings.Name %>',
                        width: '30%',
                        inputClass: 'validate[required]'
                    },
                    Description: {
                        title: '<%=GlobalStrings.Description %>',
                        width: '40%',
                        type: 'textarea',
                        list: false
                    },
                    SortOrder: {
                        title: '<%=GlobalStrings.SortOrder %>',
                        width: '10%',
                        defaultValue: '0',
                        inputClass: 'validate[required,custom[integer]]'
                    },
                    Hidden: {
                        title: '<%=GlobalStrings.Hidden %>',
                        width: '10%',
                        type: 'checkbox',
                        values: { 'false': 'NO', 'true': 'YES' },
                        defaultValue: 'false'
                    },
                    Edit: {
                        title: '',
                        width: '1%',
                        display: function (data) {
                            return '<input class="jtable-command-button jtable-edit-command-button" onclick="javascript:window.location=\'EditGroup.aspx?id=' + data.record.Id + '\';" />';
                        }
                    }
                },

                //Initialize validation logic when a form is created
                formCreated: function (event, data) {
                    data.form.validationEngine();
                },
                //Validate form when it is being submitted
                formSubmitting: function (event, data) {
                    return data.form.validationEngine('validate');
                },
                //Dispose validation logic when form is closed
                formClosed: function (event, data) {
                    data.form.validationEngine('hide');
                    data.form.validationEngine('detach');
                }
            });

            $('#SupplierGroupsTableContainer').jtable('load');
        });
    </script>
</asp:Content>
